
import 'index_data.dart';

class GoodsBean {
  int? _id;
  String? _name;
  int? _originalPrice;
  int? _price;
  String? _discountRate;
  String? _img;

  int? get id => _id;

  String? get name => _name;

  int? get originalPrice => _originalPrice;

  int? get price => _price;

  String? get discountRate => _discountRate;

  String? get img => _img;

  GoodsBean(
      {int? id,
        String? name,
        int? originalPrice,
        int? price,
        String? discountRate,
        String? img,}) {
    _id = id;
    _name = name;
    _originalPrice = originalPrice;
    _price = price;
    _discountRate = discountRate;
    _img = img;
  }

  GoodsBean.fromJson(dynamic json) {
    _id = json['id'];
    _name = json['name'];
    _originalPrice = json['original_price'];
    _price = json['price'];
    _discountRate = json['discount_rate'];
    _img = json['img'];
  }

  Map<String, dynamic> toJson() {
    var map = <String, dynamic>{};
    map['id'] = _id;
    map['name'] = _name;
    map['original_price'] = _originalPrice;
    map['price'] = _price;
    map['discount_rate'] = _discountRate;
    map['img'] = _img;
    return map;
  }

  GoodsBean? parse(Object goods){
    if(goods is Recommend_goods) {
      return GoodsBean.fromJson(goods.toJson());
    }/*else if(goods is CategoryListBean){
      return GoodsBean.fromJson(goods.toJson());
    }else if(goods is Goods){
      return GoodsBean.fromJson(goods.toJson());
    }*/
    return null;
  }

}